// api.js
import axios from 'axios';

const API_BASE_URL = 'http://192.168.61.84:8000';

const OpenApi = {
    //获取验证码
  getCaptcha: () => {
    return axios.get(`${API_BASE_URL}/user/v1/base/captche`);
  },
  //密码登录
  passwordLogin: (mobile, password, captcha, captchaId) => {
    return axios.post(`${API_BASE_URL}/user/v1/user/passwordlogin`, {
      mobile,
      password,
      captcha,
      captcha_id: captchaId,
    });
  },
  //验证码登录
  loginByCode: (phone, code) => {
    return axios.post(`${API_BASE_URL}/open/noPassLogin`, {
      phoneNumber: phone,
      verifyCode: code,
    });
  },
  //注册
  register: (userName, realname, mobile, password, eqPassword, identify) => {
    return axios.post(`${API_BASE_URL}/user/v1/user/register`, {
      user_name: userName,
      name: realname,
      mobile: mobile,
      password: password,
      eq_password: eqPassword,
      identify: identify,
      roleid: 2,
    });
  },
  //获取用户列表
  fetchUsers: () => {
    return axios.get(`${API_BASE_URL}/user/v1/user/list?pn=1`, {
      headers: {
        x_token: localStorage.getItem("token"),
      },
    });
  },
  //删除用户
  deleteUser: (userID) => {
    return axios.delete(`${API_BASE_URL}/user/v1/user/deleteuser`, {
      headers: {
        x_token: localStorage.getItem("token"),
      },
      data: {
        userID: userID,
      },
    });
  },
  // 其他请求
};

export default OpenApi;
